package com.rm.zeyou.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import com.rm.zeyou.entity.User;
import com.rm.zeyou.response.ApiRestResponse;
import com.rm.zeyou.service.UserZfbCountService;
import com.rm.zeyou.util.login.LoginUtil;
import com.rm.zeyou.voice.vo.request.AddZfbCountVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 用户支付宝账户表 前端控制器
 * </p>
 *
 * @author YanYang
 * @since 2025-04-16 15:58:56
 */
@Api(tags = "用户支付宝相关")
@RestController
@RequestMapping("/api/userZfbCount")
public class UserZfbCountController {

    @Resource
    private UserZfbCountService userZfbCountService;
    @Resource
    private LoginUtil loginUtil;

    @ApiOperation("添加支付宝账户")
    @PostMapping("addUserZfbCount")
    @SaCheckLogin(type = "user")
    public ApiRestResponse<Integer> addUserZfbCount(@RequestBody AddZfbCountVo requestVo)  {
        User user = loginUtil.getUser();
        return userZfbCountService.addZfbCount(user.getId(),requestVo);
    }

    @ApiOperation("查看支付宝账户")
    @GetMapping("selectUserZfbCount")
    @SaCheckLogin(type = "user")
    public ApiRestResponse<AddZfbCountVo> selectUserZfbCount()  {
        User user = loginUtil.getUser();
        return userZfbCountService.selectUserZfbCount(user.getId());
    }

    @ApiOperation("查看支付宝账户")
    @PostMapping("updateUserZfbCount")
    @SaCheckLogin(type = "user")
    public ApiRestResponse<Integer> updateUserZfbCount(@RequestBody AddZfbCountVo requestVo)  {
        User user = loginUtil.getUser();
        return userZfbCountService.updateUserZfbCount(user.getId(),requestVo);
    }

}
